package com.fuershiye.woman.monitor.controller;

import com.fuershiye.woman.monitor.beans.Page;
import com.fuershiye.woman.monitor.beans.PageResult;
import com.fuershiye.woman.monitor.beans.Result;
import com.fuershiye.woman.monitor.beans.ViewUser;
import com.fuershiye.woman.monitor.constants.Massage;
import com.fuershiye.woman.monitor.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping(value = "/user")
public class UserController {
    @Autowired
    AdminService adminService;

//    @RequiresPermissions("manager:userList")
    @RequestMapping(value = "/list.do")
    @ResponseBody
    public Result list(String name, Integer page,  Integer pageSize) {

        //1:正常；2：禁用；3：未激活;
        int status = 1;
        pageSize = 3000;

        List<ViewUser> result = adminService.listByCondition(name, status, new Page(page, pageSize));
        int size = adminService.countByCondition(name, status);

        return new Result(Massage.SUCCESS, new PageResult(result, size));

    }
}
